from multiprocessing import  Process, Lock

from pachong import *

if __name__ == '__main__':
    lock = Lock()   
    process_list = [
        Process(target=update_up_data, args=(lock,)),
        Process(target=update_video_data_7d, args=(lock,))
    ]
    target_list = [
        update_up_data, 
        update_video_data_7d
        ]
    for process in process_list:
        process.start()
        time.sleep(5)

    while True:
        for i,process in enumerate(process_list):
            if not process.is_alive():
                print(f"进程{i}已退出")
                process_list[i] = Process(target=target_list[i], args=(lock,))
                process_list[i].start()
                print(f"进程{i}已重启")
        time.sleep(10)